<?php
defined('SYSPATH') OR die('No direct access allowed.');
/**
 * materialin.php
 * @author ranuandra
 *
 * 14 Agu 2011 23:58:56
 *
 * 
 */

class Model_Materialin extends ORM
{
   protected $_has_many= array(
								'detailmaterialin' 	=> array('model' => 'detailmaterialin'),
							);
   protected $_belongs_to = array(
								'supplier' 	=> array('model' => 'supplier'),
							);
	
	private $_form = array('supplier_id' 		=> '',
							'tgl'				=> '',
							'location_id'		=> '',
							'no_order'			=> '',
							'truck_number'		=> '',
							);
							
	private $_field = array(
						'supplier_id', 'tgl', 'location_id', 'no_order', 'truck_number'
					);

	public function rules()
	{
		return array(
			'supplier_id' 	  	=> array(
			 						array('min_length', array(':value', 0)),
			 ),
			 'tgl' 	   			=> array(
			 						array('min_length', array(':value', 0)),
			 ),
			'location_id' 	   => array(
			 						array('min_length', array(':value', 0)),
			 ),
			'no_order' 	   		=> array(
			 						array('min_length', array(':value', 0)),
			 ),
			'truck_number' 	   => array(
			 						array('min_length', array(':value', 0)),
			 )

		);
	}
	
	public function get_form()
	{
		return $this->_form;
	}
	
	public function get_field()
	{
		return $this->_field;
	}
	
	public function create_materialin($values)
	{
		return $this->values($values, $this->_field)->create();
	}
}